package org.opens.mybatisplus.controller;

import lombok.Data;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping(value = "/api/param")
public class WebParamController {

    /**
     * 功能:
     *      使用双层List作为参数.
     * 参数形式:
     *      {
     *          "id": 1,
     *          "listParam": [
     *              [
     *                  {
     *                      "id": 2,
     *                      "name": "s2"
     *                  },
     *                  {
     *                      "id": 3,
     *                      "name": "s3"
     *                  }
     *              ],
     *              [
     *                  {
     *                      "id": 4,
     *                      "name": "s4"
     *                  },
     *                  {
     *                      "id": 5,
     *                      "name": "s5"
     *                  }
     *              ]
     *          ]
     *      }
     */
    @RequestMapping(value = "/double/list")
    public DoubleListParam paramOne(
            @RequestBody DoubleListParam doubleListParam
    ) {
        return doubleListParam;
    }

    @Data
    public static class DoubleListParam {

        private Integer id;

        private List<List<ObjectParam>> listParam;

    }

    @Data
    public static class ObjectParam {

        private Integer id;

        private String name;

    }

}
